package com.dyh.quickdemo.depRm3;

import com.google.common.base.Function;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

@Configuration
public class EnhanceLambdaBeanRegister implements ApplicationContextAware {



    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationContext
                .getAutowireCapableBeanFactory();


//        Function<SdkRequest,? extends SdkResponse> oldBean = (Function<SdkRequest,? extends SdkResponse>) beanFactory.getBean("sdkClientExe");
//        HelloResponse helloResponse = new HelloResponse();
//        helloResponse.setData("fake!");
//        Function<SdkRequest,? extends SdkResponse> newBean = e->helloResponse;
//        beanFactory.removeBeanDefinition("sdkClientExe");//lambda 不能移
//        beanFactory.registerSingleton("sdkClientExe",newBean);
    }


}
